<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script type="text/javascript" src="static/js/jquery.min.js"></script>
    <script type="text/javascript"
            src="static/js/bootstrap/js/bootstrap.min.js"></script>
    <link rel="stylesheet"
          href="static/js/bootstrap/css/bootstrap.min.css" />
    <link rel="stylesheet"
          href="static/js/bootstrap/css/bootstrap-treeview.min.css"
          th:href="@{static/js/bootstrap/css/bootstrap-treeview.min.css}"
    >
    <script src="static/js/bootstrap/js/bootstrap-treeview.min.js"></script>
    <link rel="stylesheet"
          href="static/js/bootstrap/css/bootstrap.addtabs.css">
    <script src="static/js/bootstrap/js/bootstrap.addtabs.min.js"></script>
    <link rel="stylesheet" href="static//js/bootstrap/css/bootstrap-table.min.css">
    <script src="static/js/bootstrap/js/bootstrap-table.min.js"></script>
    <script src="static/js/bootstrap/js/bootstrap-table-zh-CN.min.js"></script>
    <script src="static/js/bootstrap/js/bootbox.js"></script>
    <link rel="stylesheet"
          href="static/js/bootstrap/css/bootstrap-datetimepicker.min.css" />
    <script type="text/javascript"
            src="static/js/bootstrap/js/bootstrap-datetimepicker.min.js"></script>
    <script type="text/javascript"
            src="static/js/bootstrap/js/bootstrap-datetimepicker.zh-CN.js"></script>
    <script src="static/js/bootstrap-fileinput/js/fileinput.js"></script>
    <script src="static/js/bootstrap-fileinput/js/locales/zh.js"></script>
    <link rel="stylesheet" href="static/js/bootstrap-fileinput/css/fileinput.css">
    <script src="https://cdn.jsdelivr.net/npm/bootstrap-select@1.13.18/dist/js/bootstrap-select.min.js"></script>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-select@1.13.18/dist/css/bootstrap-select.min.css">
</head>
<body onload="showSel()" >
<div id="toolBar">
    <div className="form-group">
        <label htmlFor="orderDesc">项目名称:</label>
        <input type="text" className="form-control" id="productName"/>

        <label htmlFor="orderDesc">状态:</label>
        <select class="selectpicker form-control" data-width="150px" style="" id="queryPictureState"></select>

        <label htmlFor="orderDesc">活动时间:</label>
        <input type="date" className="form-control" id="starDate"/>
        <input type="date" className="form-control" id="endDate"/>

        <button type="button" onClick="search()" className="btn btn-info glyphicon glyphicon-search">搜索</button>
    </div>
</div>


<table id="myTable"></table>
</body>
<script type="text/javascript">


    $(function (){
        $("#myTable").bootstrapTable({
            url:"/getPictureTable",
            columns:[
                {checkbox:true},//是否展示复选框
                {field:'productId',title:'项目编码',align:'center',width:150},
                {field:'productName',title:'项目名称',align:'center',width:150,formatter:function (value, row){
                        return "<a href='javascript:jumpToPictureParticulars(\""+row.queryPictureId+"\",\""+row.productId+"\")'>"+value+"</a>";
                    }},
                {field:'queryPictureState',title:'状态',align:'center',width:150,
                    formatter:function (value,row){
                        if (row.queryPictureState == 7) {
                            if (row.fileStatus == 0) {
                                return "待接单";
                            } else  {
                                return "待定图";
                            }
                        }
                        if (row.queryPictureState == 8 && row.fileStatus == 1 && row.fileStatusTo == 1) {
                            return "已定图"
                        }else if(row.queryPictureState == 8 && row.fileStatus == 1 && row.fileStatusTo == 0){
                            return "未定图"
                        }else if(row.queryPictureState == 8 && row.fileStatus == 0 && row.fileStatusTo == 0){
                            return "已结束"
                        }
                        if (row.queryPictureState == 5) {
                            return "待接单"
                        }
                    }
                },
                {field:'queryPictureStartDate',title:'开始时间',align:'center',width:150},
                {field:'queryPictureEndDate',title:'结束时间',align:'center',width:150},
                {field:'cz',title:'操作',formatter:function(value,row){
                        var str = "";
                        if(row.queryPictureState == 5){
                            str+="| <a href='javascript:jumpToOrderReceiving(\""+row.queryPictureId+"\",\""+row.productId+"\")'>接单</a> |";
                        }
                        else if(row.queryPictureState == 6){
                            str+="| <a href='javascript:showMaterials(\""+row.queryPictureId+"\")'>上传</a> |";
                        }else if(row.queryPictureState == 7){
                            //str+="| <a href='javascript:examineQueryPirce(\""+row.queryPictureId+"\",\""+row.contacts+"\",\""+row.productName+"\")'>查看</a> |";
                            //str+="| <a href='javascript:jumpToUpdatePicture(\""+row.queryPictureId+"\",\""+row.productId+"\")'>修改</a> |";
                            if(row.fileStatus == 0){
                                str+="| <a href='javascript:jumpToOrderReceiving(\""+row.queryPictureId+"\",\""+row.productId+"\")'>接单</a> |";
                            }else if(row.fileStatus == 1){
                                str+="| <a href='javascript:examineQueryPirce(\""+row.queryPictureId+"\",\""+row.productId+"\",\""+row.contacts+"\",\""+row.productName+"\")'>查看</a> |";
                                str+="| <a href='javascript:jumpToUpdatePicture(\""+row.queryPictureId+"\",\""+row.productId+"\")'>修改</a> |";
                            }
                        }else if(row.queryPictureState == 8){
                            if(row.fileStatus == 1 && row.fileStatusTo == 1) {
                                str+="| <a href='javascript:examineQueryPirce(\""+row.queryPictureId+"\",\""+row.productId+"\",\""+row.contacts+"\",\""+row.productName+"\")'>查看</a> |";
                            }else if(row.fileStatus == 1 && row.fileStatusTo == 0){
                                str += "未被定图";
                            }else if(row.fileStatus == 0 && row.fileStatusTo == 0){

                            }
                        }else{
                            str+="";
                        }

                        return str;
                    }}
            ],
            //开启分页以后，默认会传入两个参数,而这两个参数，直接是mysql的分页计算后的数据
            pagination:true,
            pageSize:2,
            pageList:[2,4,6,8,10],
            sidePagination : 'client',//server:服务器端分页{rows:[],total:10}|client：前端分页 [{},{}]
            toolbar:'#toolBar',
            queryParams:function(){
                var productName = $("#productName").val();
                var queryPictureState = $("#queryPictureState").val();
                var starDate = $("#starDate").val();
                var endDate = $("#endDate").val();
                return {
                    'productName':productName,
                    'starDate':starDate,
                    'endDate':endDate,
                    'queryPictureState':queryPictureState
                };
            },

        })
    })


    /**
     * 跳转询图详情页面
     */
    function jumpToPictureParticulars(queryPictureId,productId){
        location.href="jumpToPictureParticulars?queryPictureId="+queryPictureId+"&productId="+productId;
    }


    function showSel(){
        $.ajax({
            "type" : 'get',
            "url": 'getPictureSelectClass',
            "dataType" : "json",
            "success" : function(data) {
                var arr = data;
                var opts = "";
                for( var i = 0 ; i < arr.length; i++ ){
                    var depart = arr[i];
                    opts += "<option value='"+depart.statusId+"'>"+depart.statusName+"</option>";
                }
                // 查询界面
                $("#queryPictureState").append(opts);
                $("#queryPictureState").selectpicker("refresh");
            }
        });
    }
    /**
     * 条查
     */
    function search(){
        $('#myTable').bootstrapTable('refresh');
    }


    /**
     * 跳转修改询图单页面
     *
     */
    function jumpToUpdatePicture(queryPictureId,productId){
        location.href="jumpToUpdatePicture?queryPictureId="+queryPictureId+"&productId="+productId;
    }


    /**
     * 查看询图单详情
     * @param queryPictureId 询图单id
     * @param contacts  联系人
     * @param productName 项目名称
     */
    function examineQueryPirce(queryPictureId,productId,contacts,productName){

        location.href="examineQueryPirce?queryPictureId="+queryPictureId+"&contacts="+contacts+"&productName="+productName+"&productId="+productId;
    }



    /**
     * 询图单接单
     * @param queryPictureId
     * @param productId
     */
    function jumpToOrderReceiving(queryPictureId,productId){
        location.href="jumpToOrderReceiving?queryPictureId="+queryPictureId+"&pid="+productId;
    }



</script>
</html>